package com.zoe.onelink.logging.trace.exception;

import brave.Span;
import brave.Tracer;
import com.zoe.onelink.common.entity.ResultVO;
import com.zoe.onelink.core.exception.interceptor.WebExceptionInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * <p>标题: Web异常监听器</p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2021</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2021-08-12
 */
@RequiredArgsConstructor
@Order(Ordered.HIGHEST_PRECEDENCE)
public class TraceWebExceptionInterceptor implements WebExceptionInterceptor {

    private final Tracer tracer;

    @Override
    public Exception afterHandle(Exception ex, ResultVO<Object> resultVO) {
        Span span = this.tracer.currentSpan();
        span.error(ex);
        return ex;
    }
}
